/*
 * Copyright (c) 2007 The Trustees of Indiana University. All rights reserved.
 * IU CSCI B534 Distributed Systems 2007-02-01 http://www.cs.indiana.edu/classes/b534
 */

package edu.indiana.cs.b534.torrent.impl;

import edu.indiana.cs.b534.torrent.TorrentException;
import edu.indiana.cs.b534.torrent.context.TorrentContext;

/**
 * Interface to communicate with the manager of pieces
 */
public interface PieceManager {

    // get next piece to download
   // public PieceInfo getPieceToDownload(byte[] availableBitField);

    // check if SHA1hash(piece) validates against its expected SHA1 hash value
    // if so, return true; else return false
    public boolean setPieceDownloaded(PieceInfo piece, String peerId)throws TorrentException;

    // cancel a piece that was flagged as being downloaded
    public void cancelPieceDownload(PieceInfo piece);

    // return a piece that we already have
    public PieceInfo getPieceInfo(int index);

    /**
     * This method will be called when a peer instance receives an interested message from a peer
     * @param peerInstance
     * @return - whether piece manager respects the interested request or not
     */
    public boolean interestedMessageReceived(PeerInstance peerInstance);

    public TorrentContext getTorrentContext();
}

